package com.wnhz.work.yz.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.wnhz.work.yz.BaseActivity;
import com.wnhz.work.yz.R;

/**
 * @author zxb
 * @date 2016/12/19
 * @describe 产业园接待行程
 */
public class NewTravelActivity extends BaseActivity implements View.OnClickListener {
    private static final String TAG = "NewTravelActivity";

    private TextView tv_newTravel_start;
    private TextView tv_newTravel_address;

    private static final int CHOOSE_TIME = 215;
    private static final int CHOOSE_ADDRESS = 216;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new_travel);

        initTitle();
        initView();
    }


    private TextView title;

    private void initTitle() {
        title = (TextView) findViewById(R.id.view_main_middle_title);
        title.setText("产业园接待行程");
        findViewById(R.id.btn_main_left).setOnClickListener(this);
        TextView tv_right = (TextView) findViewById(R.id.view_main_right_text);
        tv_right.setText("保存");
        tv_right.setTextColor(Color.parseColor("#008c99"));
        tv_right.setVisibility(View.VISIBLE);
        findViewById(R.id.btn_main_right).setVisibility(View.VISIBLE);
        findViewById(R.id.btn_main_right).setOnClickListener(this);
    }

    private void initView() {
        tv_newTravel_start = (TextView) findViewById(R.id.tv_newTravel_start);
        tv_newTravel_address = (TextView) findViewById(R.id.tv_newTravel_address);


        findViewById(R.id.rl_newTravel_start).setOnClickListener(this);
        findViewById(R.id.rl_newTravel_address).setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {

            case R.id.btn_main_left:

                finish();
                break;
            //保存
            case R.id.btn_main_right:
                MyToast("保存");

                break;
            //行程开始时间
            case R.id.rl_newTravel_start:
//                intent = new Intent(this, DriverPickActivity.class);
//                startActivity(intent);
                break;

            //行程地点
            case R.id.rl_newTravel_address:
                intent = new Intent(this, TravelAddressPickActivity.class);
                startActivityForResult(intent, CHOOSE_ADDRESS);
                break;


            default:
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        switch (requestCode) {
            case CHOOSE_ADDRESS:
                if (resultCode == RESULT_OK) {
                    if (null != data) {
                        String getAddress = data.getStringExtra("address");
                        tv_newTravel_address.setText(getAddress);
                    }
                }
                break;
            default:
                break;
        }
    }
}
